/* week05 实验2 对实验1的逻辑结构进行改进
swtich(表达式)
{
    case 表达式值1 执行语句1;break;
    case 表达式值2 执行语句2;break;
    ...  ........ ........;break;
}
输入一个学生的成绩(百分制)，输出该学生的成绩和对应的等级
A:90~100
B:80~89 85/10-->8, 88/10 -->8
C:70~79
D:60~69
F:0~59
1.输入  85
2.输出 x=85 is grade B!
*/
#include <stdio.h>
int main(){
    int grade;
    printf("Please enter a score(1~100):");
    scanf("%d",&grade);
    //分段的判别
    if(grade > 100 || grade <0){
        printf("Valid value!\n");
    }
    else
    {
        switch (grade/10)
        {
        case 9:
            printf("x=%d is grade A!\n",grade);
            break;
        case 8:
            printf("x=%d is grade B!\n",grade);break;
        case 7:
            printf("x=%d is grade C!\n",grade);break;
        case 6:
            printf("x=%d is grade D!\n",grade);break;
        default:
            printf("Fail in the exam!\n");
            break;
        }
    }
    
    return 0;
}